<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<style>

#cdiTable th{
	width: 70px;
}
</style>

<c:if test="${showReport != null }">

<div >

<h2>客訴案件統計</h2>

<p>
搜尋欄位: 
<c:if test="${searchType == 'startDate' }">
	開單日期
</c:if>
<c:if test="${searchType == 'fdDate' }">
	判定完成日期
</c:if>
</p>

<p>
搜尋期間: ${searchDate } ~ ${endSearchDate }
</p>

<p>
當月計算期間:${startSearchDate}~ ${endSearchDate }
</p>

<c:if test="${not empty cdiList}">
	<div><a href="${excelFileUrl }"><spring:message code="report.download"/></a></div>
</c:if>


<c:if test="${isShowDetail==false}">

<c:set var="dutyMap" value="${objs0702[0]}"></c:set>
<c:set var="monthTotal" value="${objs0702[1]}"></c:set>
<c:set var="monthTotalOfAll" value="${objs0702[2]}"></c:set>

<table id="report0702" border="1" class="tablesorter" style="width: ${fn:length(dutyMap)*190}px;">
	<thead>
		<tr>			
			<th>權責單位</th>
			<c:forEach var="duty" items="${dutyMap}">
				<th>${orgDesc[duty.key]}</th>
			</c:forEach>
			<th>小計   &nbsp;</th>
			<th>當月件數 </th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>成立</td>
			<c:forEach var="duty" items="${dutyMap}">
				<td>					
					<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&determine=Y&duty=${duty.key}&isSkipDuty=false&isAnyDuty=false&isShowDetail=true&searchType=${searchType}" />">${duty.value[0]}</a>	
				</td>
			</c:forEach>
			<td>				
				<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&determine=Y&isSkipDuty=false&isAnyDuty=true&isShowDetail=true&searchType=${searchType}" />">${monthTotal[0]}</a>
			</td>
			<td>				
				<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&determine=Y&isSkipDuty=true&isAnyDuty=false&isShowDetail=true&searchType=${searchType}" />">${monthTotalOfAll[0]}</a>
			</td>
		</tr>
		<tr>
			<td>不成立</td>	
			<c:forEach var="duty" items="${dutyMap}">
				<td>					
					<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&determine=N&duty=${duty.key}&isSkipDuty=false&isAnyDuty=false&isShowDetail=true&searchType=${searchType}" />">${duty.value[1]}</a>
				</td>			
			</c:forEach>
			<td>				
				<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&determine=N&isSkipDuty=false&isAnyDuty=true&isShowDetail=true&searchType=${searchType}" />">${monthTotal[1]}</a>
			</td>
			<td>				
				<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&determine=N&isSkipDuty=true&isAnyDuty=false&isShowDetail=true&searchType=${searchType}" />">${monthTotalOfAll[1]}</a>
			</td>
		</tr>	
			<td>未判定</td>
			<c:forEach var="duty" items="${dutyMap}">
				<td>					
					<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&duty=${duty.key}&isSkipDuty=false&isAnyDuty=false&isShowDetail=true&searchType=${searchType}" />">${duty.value[2]}</a>
				</td>
			</c:forEach>
			<td>				
				<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&isSkipDuty=false&isAnyDuty=true&isShowDetail=true&searchType=${searchType}" />">${monthTotal[2]}</a>
			</td>
			<td>				
				<a href="<c:url value="/report07/find.do?startSearchDate=${startSearchDate}&searchDate=${searchDate}&endSearchDate=${endSearchDate}&isSkipDuty=true&isAnyDuty=true&isShowDetail=true&searchType=${searchType}" />">${monthTotalOfAll[2]}</a>
			</td>
		<tr>	
			<td>小計</td>
			<c:forEach var="duty" items="${dutyMap}">
				<td>${duty.value[3]}</td>
			</c:forEach>
			<td>${monthTotal[3] }</td>
			<td>${monthTotalOfAll[3] }</td>
		</tr>	
	</tbody>
</table>
<p><small>* 註1:'小計'欄位只計算'權責單位'有值的部份,若該客訴單尚未填入'權責單位',則不列入計算. </small></p>
<p><small>* 註2:'小計'欄位計算的時間區間為搜尋區間. </small></p>
<p><small>* 註3:'當月件數'欄位統計的筆數不論'權責單位'有無值,都列入計算 </small></p>
<p><small>* 註4:'當月件數'欄位計算的時間區間為搜尋起始日期的當月月初 ~ 搜尋結束日期. </small></p>



<table border="1" id="cdiTable" class="tablesorter"  style="width: 1500px;"> 	
	<thead>
	<tr>
		<td colspan="9"><h2>客戶抱怨案件統計</h2></td>
	</tr>
	<tr>
	 <th style="width: 50px;" >項次</th>
	 <th>案件單號</th>
     <th>客戶</th>
     <th>新品號</th>
     <th>舊品號</th>
     <th>異常現象</th>
     <th>數量</th>
     <th>製造地</th>
     <th>客戶抱怨原因</th>
</tr>
</thead>
	
	<tbody>
	
	<c:if test="${empty cdiList}">
		<tr>
     		<td colspan="8" >${searchDate}當日查無客訴資料</td>
     	</tr>
	</c:if>
	
	<c:forEach var="cdi" items="${cdiList}" varStatus="status">
	
	<tr>
     <td>${status.index+1}</td>
     <td>
     	${cdi.CDIID}
     </td>
     <td>
     	${cdi.custID}
     </td>
     <td>${cdi.newProduct}</td>
     <td>${cdi.oldProduct}</td>
     <td>${cdi.unusualType}</td>
     <td>${cdi.unusualRoll}</td>
     <td>${cdi.madeIn} (${cdi.productType})</td>
     <td>${cdi.CDINote}</td>
	</tr>
	
	</c:forEach>
	<tr style="font-size:16px;font-weight: bold;" >
		<td></td>
		<td><b>搜尋期間件數</b></td>
		<td>${fn:length(cdiList)}</td>
		<td>件</td>
		<td>(當月)累計件數</td>
		<td>${monthCount }</td>
		<td colspan="2">件</td>
	</tr>
	</tbody>
</table>

</c:if>



<c:if test="${isShowDetail==true}">
<br>

<c:choose>
	<c:when test="${determine eq 'Y'}">當月判定成立件數:${detailCount}</c:when>
	<c:when test="${determine eq 'N'}">當月判定不成立件數:${detailCount}</c:when>
	<c:otherwise>當月待判定件數:${detailCount}</c:otherwise>
</c:choose>

<input type="button" value="回上一層表單" onclick="window.history.back()"> 

<table id="report070345" border="1" class="tablesorter" style="width: 2000px;">
	<thead>
		<tr>
			<th>月份</th>
			<th>案件單號</th>
			<th>流程狀態</th>
			<th>逾期否</th>
			<th>階段執行者</th>
			<th>生產地</th>
			<th>客戶</th>
			<th>新品號</th>
			<th>舊品號</th>
			<th>異常現象</th>
			<th width="100px" >權責單位</th>
			<th width="100px" >判定日期</th>
			<th>判定原則</th>
			<th>判定說明</th>
			<th>工作清單連結</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="d" items="${detailList}" >
			<tr>
				<td>${fn:substring(d.CDIID, 7, 9)}</td>
				<td>${d.CDIID}</td>
				<td>${d.status}</td>
				<td>
					<c:if test="${d.exp}">
						是
					</c:if>
					<c:if test="${ not d.exp}">
						否
					</c:if>
				</td>
				<td>${d.sendtodoId_ct}</td>
				<td>${madeIns[d.madeIn]}</td>
				<td>${customerNames[d.custID]}</td>
				<td>${d.newProduct}</td>
				<td>${d.oldProduct}</td>
				<td>${unusualTypes[d.unusualType]}</td>
				<td>${orgDesc[d.dutyUnit6_2]}</td>
				<td>${fn:substring(d.finishDetetmineDate6,0,10)}</td>
				<td>${dtermineP6[d.detetminePrinciple6]}</td>
				<td>${d.memo6}</td>
				<td><a href="<c:url value="/report07/0703/find.do?CDIID=${d.CDIID}" /> ">${d.todoCount}</a></td>
			</tr>
		</c:forEach>
	</tbody>
</table>
</c:if>

</div>

</c:if>

<script>
$(function() {
	$("#cdiTable").tablesorter({
		widgets: ['zebra']
		});
	$("#report0702").tablesorter({
		widgets: ['zebra'],
		headers: { 
        0: { 
            sorter: false 
        }, 
        1: { 
            sorter: false 
        },
        2: { 
            sorter: false 
        },
        3: { 
            sorter: false 
        } 
    	} 
	});
	$("#report070345").tablesorter({
		widgets: ['zebra'],
		headers: { 
        0: { 
            sorter: false 
        }, 
        1: { 
            sorter: false 
        },
        2: { 
            sorter: false 
        },
        3: { 
            sorter: false 
        }, 
        4: { 
            sorter: false 
        } ,
        5: { 
            sorter: false 
        } ,
        6: { 
            sorter: false 
        } ,
        7: { 
            sorter: false 
        } ,
        8: { 
            sorter: false 
        } ,
        9: { 
            sorter: false 
        } 
    	} 
	});  
	
	
})

</script>


